export default class musicFormat {
  /* 时间格式化 */
  timeFormat(time: number): string {
    let timeStr: string
    if (time < 600) {
      timeStr = '0' + Math.floor(time / 60)
      if (time % 60 < 10) {
        timeStr += ':0' + Math.floor(time % 60)
        return timeStr
      } else {
        timeStr += ':' + Math.floor(time % 60)
        return timeStr
      }
    }
    return '00:00'
  }
  /* 歌词格式化 */
  lyricFormat(lyric: string): any[] {
    let lyricList = <any>[]
    const timeList = <any>[]
    const wordList = <any>[]
    lyricList = lyric.split('\n')
    for (let i = 0; i < lyricList.length; i++) {
      timeList[i] = lyricList[i].split(']')[0].split('.')[0].replace('[', '')
      wordList[i] = lyricList[i].split(']')[1]
    }
    return [timeList, wordList]
  }
  /* 播放列表将当前播放歌曲放到首位 */
  playListReset(arr: any[], currentIndex: number): any[] {
    const arr1 = arr.slice(currentIndex)
    const arr2 = arr.slice(0, currentIndex)
    const arrRes = arr1.concat(arr2)

    return arrRes
  }
}
